#!/usr/bin/env bash
echo "Easy Fuser Mount Archive For Ubuntu"
echo "依赖软件: fuse-zip fuseiso9660 archivemount libfile-mimeinfo-perl"
bname=`basename $1`
#mimetype
#fonts.zip: application/zip
#fonts.tar: application/x-tar
#fonts.tar.gz: application/x-compressed-tar
#fonts.tgz: application/x-compressed-tar
#fonts.tar.bz2: application/x-bzip-compressed-tar 
#bionic-desktop-amd64.iso: application/x-cd-image
t=`mimetype $1`
t=`echo $t | awk -F: '{print $2}'` 
t=`echo $t | awk -F/ '{print $2}'` 
echo $bname : $t
mkdir -p ~/mnt
case $t in
zip)        cmd=fuse-zip;;
x-cd-image) cmd=fuseiso9660;;
x*-tar)     cmd=archivemount;;
*)          echo error format;;
esac

select charset in utf-8 cp936
do
    break
done
echo $cmd -o ro,modules=iconv,from_code=$charset $1 ~/mnt/${bname}
mkdir -p ~/mnt/${bname}
$cmd -o ro,modules=iconv,from_code=$charset $1 ~/mnt/${bname}
echo 挂载点： ~/mnt/${bname} 
